package org.anti996.ln_mybatis;

import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.OutputFile;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;

import java.util.Collections;

public class CodeGenerator {
    public static void main(String[] args) {
        String outputDir = "/home/hamlet/Codebase/Homework/ln_mybatis/src/main/";
        FastAutoGenerator.create("jdbc:mysql://127.0.0.1:3306/bank", "hamlet", "fpl0314")
                .globalConfig(builder -> builder
                        .author("Anti996 Authors")
                        .enableSwagger()
                        .fileOverride()
                        .outputDir(outputDir + "java"))
                .packageConfig(builder -> builder
                        .parent("org.anti996")
                        .entity("model")
                        .moduleName("ln_mybatis")
                        .pathInfo(Collections.singletonMap(OutputFile.xml, outputDir + "resources/mappers")))
                .strategyConfig(builder -> builder
                        .addInclude("account", "card", "exchange_rate", "record")
                        .entityBuilder()
                        .enableLombok()
                        .controllerBuilder()
                        .enableRestStyle()
                        .serviceBuilder()
                        .formatServiceFileName("%sService"))
                .templateEngine(new FreemarkerTemplateEngine())
                .execute();
    }
}
